<?php
/**
  * M_user model 文件
  * @author Cuil <lntschampion@163.com> 
  * @date 2016-02-15
  */
class M_user extends MY_Model{
	
	public $table = "t_user";
	function __construct() {
		parent::__construct ();
	}
	//通过用户名查询用户信息
	function getUser($user_name){
		$info = $this->query($this->table,array('LoginName'=>$user_name));
		if($info){
			$info = $info[0];
		}
		return $info;
	}
	//通过用户名查询出用户职务
	function getTitle($user_name){
                     $sql="SELECT r.RoleName FROM t_user u LEFT JOIN t_auth_multiple m ON m.UserID=u.PID LEFT JOIN t_auth_roles r ON r.Id=m.RoleId WHERE u.LoginName="."'".$user_name."'"."AND (r.Id=6 or r.Id=36 OR r.Id=33 OR r.Id=35)";
                     $title = $this->query_one($sql);
                     return $title;

	}

	//通过用户id查询用户信息
	function getUserById($userId){
	
		$info = $this->query($this->table,array('PID'=>$userId));
		if($info){
			$info = $info[0];
		}
		return $info;
	}
	//修改记录
	function query_update($data,$where){
		 
		$user = $this->update($this->table,$data,$where);
		return $user;
	}
	 
	//查询数量
	function getUserCount($where){
	
		$info = $this->queryCount($this->table,$where);
		return $info;
	}

	
	//查询列表
	function query_list($where = array(),$filed='*',$limit,$offset){
		$medias = $this->query($this->table,$where,$filed,$limit,$offset);
		return $medias;
	}
}	